# _*_ coding : utf-8 _*_
# @Time: 2024/10/29 10:38
# @Author : 石文帅	
# @File : testcase07-2分类资源
# @Project : python_slfh
from server.slfhWorkbench import *
from selenium.webdriver.chrome.service import Service
from xpathDictionary.slfhXpath import *


class test(unittest.TestCase):

    @classmethod
    def setUpClass(cls):
        cls.wd = webdriver.Chrome(service=Service(driver_path))
        cls.wd.get(url_path)
        cls.wd.maximize_window()
        login(cls.wd)

    @classmethod
    def tearDownClass(cls):
        log.info('删除数据操作')
        locate_input(cls.wd, resources['分类资源-资源名称输入框'], '分类资源测试')
        resource_del(cls.wd, resource_name='分类资源测试')
        cls.wd.quit()
        log.info('----------------------------------------------------------')

    def testcase07_2分类资源(self):
        """
        分类资源 导入测试
        :return:
        """
        log.info('testcase07_2分类资源')
        search_menu(self.wd, '分类资源')
        log.info('导入失败无必填标头测试')
        upload_file_by_input(self.wd, resources['分类资源-导入input'], f'{path_file}分类资源-失败导入无表头.zip')
        time.sleep(1)
        text = element_exist_gettext(self.wd, resources['分类资源-导入报错提示'], 5)
        assert_equal(text, '模板错误！,缺少【资源类别（必填）】列')

        log.info('导入失败无分类资源类型测试')
        upload_file_by_input(self.wd, resources['分类资源-导入input'], f'{path_file}分类资源-失败导入无分类资源类型.zip')
        time.sleep(1)
        text = element_exist_gettext(self.wd, resources['分类资源-导入报错下载提示'], 5)
        assert_equal(text, '导入数据失败，是否下载详细错误信息文件?')
        locate_click(self.wd, resources['分类资源-导入报错下载取消'])
        time.sleep(2)

        log.info('导入成功测试')
        upload_file_by_input(self.wd, resources['分类资源-导入input'], f'{path_file}分类资源-成功导入.zip')
        time.sleep(1)
        assert_true(element_exist(self.wd, resources['资源列表成功提示'], 10))



